# 113 类和对象
# class Clock:
#     id = None
#     price = None
#
#     def ring(self):
#         import winsound
#         winsound.Beep(2000, 3000)
#
#
# clock1 = Clock()
# clock1.id = '001'
# clock1.price = 19.99
#
# print(f"闹钟ID:{clock1.id},价格：{clock1.price}")
# clock1.ring()
#
# clock2 = Clock()
# clock2.id = '00'
# clock2.price = 19.99
#
# print(f"闹钟ID:{clock2.id},价格：{clock2.price}")
# clock2.ring()

# 114 构造方法
# class Student:
#     def __init__(self, name, age, tel):
#         self.name = name
#         self.age = age
#         self.tel = tel
#         print("Student类创建了一个类对象")
#
#
# stu = Student('周杰伦', 31, 18769785587)
# print(stu.name)
# print(stu.age)
# print(stu.tel)

"""
学生信息录入
"""

# 定义学生类
# class Student:
#     name = None  # 学生姓名
#     age = None  # 学生年龄
#     address = None  # 学生的地址
#
#     def __init__(self, name, age, address):
#         self.name = name
#         self.age = age
#         self.address = address
#
#
# # 输入学生信息
# num_students = int(input("请输入学生的数量："))
#
# for i in range(num_students):
#     print(f"请输入第{i + 1}位学生的信息")
#     name = input("姓名：")
#     age = input("年龄：")
#     address = input("地址：")
#     student = Student(name, age, address)
#     print(f"第{i + 1}位学生，name={name},age={age},address={address}")

# 魔术方法
# class Student:
#     def __init__(self, name, age):
#         self.name = name  # 学生姓名
#         self.age = age  # 学生年龄
#
#     # __str__魔术方法
#     def __str__(self):
#         return f"Student类对象，name:{self.name}, age:{self.age}"
#
#     # __lt__魔术方法
#     def __lt__(self, other):
#         return self.age < other.age
#
#     # __le__魔术方法
#     def __le__(self, other):
#         return self.age <= other.age
#
#     # __eq__魔术方法
#     def __eq__(self, other):
#         return self.age == other.age
#
#
# stu1 = Student("周杰轮", 31)
# stu2 = Student("林俊节", 36)
# print(stu1 == stu2)

# 116 封装
# 定义一个类，内含私有成员变量和私有成员方法
# class Phone:
#     __current_voltage = 0.5
#
#     def __keep_single_core(self):
#         print("让CPU以单核的模式运行")
#
#     def call_by_5G(self):
#         if self.__current_voltage >= 1:
#             print("5G通话已经开启")
#         else:
#             self.__keep_single_core()
#             print("电量不足，无法使用5G")
#
#
# phone = Phone()
# phone.call_by_5G()


# 117 练习
# class Phone:
#     __is_5G_enable = False
#
#     def __check_5G(self):
#         if self.__is_5G_enable == True:
#             print("5G开启")
#         else:
#             print("5G关闭，使用4G网络")
#
#     def call_by_5G(self):
#         self.__check_5G()
#         print("正在通话中")
#
#
# phone = Phone()
# phone.call_by_5G()


# 118 继承的基础语法
# class Phone:
#     IMEI = None
#     producer = 'ITCAST'
#
#     def call_by_4G(self):
#         print("4G通话")
#
#
# class Phone2022(Phone):
#     face_id = '10001'
#
#     def call_by_5G(self):
#         print("2022年新功能：5G通话")
#
#
# phone = Phone2022()
# print(phone.producer)
# phone.call_by_4G()
# phone.call_by_5G()
#
#
# # 多继承
# class NFCReader:
#     nfc_type = "第五代"
#     producer = "HM"
#
#     def read_card(self):
#         print("NFC读卡")
#
#     def write_card(self):
#         print("NFC写卡")
#
#
# class RemoteControl:
#     rc_type = "红外遥控"
#
#     def control(self):
#         print("红外遥控开启了")
#
#
# class MyPhone(Phone, NFCReader, RemoteControl):
#     pass
#
#
# phone = MyPhone()
# phone.call_by_4G()
# phone.read_card()
# phone.write_card()
# phone.control()
#
# print(phone.producer)
